import 'package:flutter/material.dart';
import 'package:xuance/constant.dart';

class ExpandedWidget extends StatelessWidget {
  final bool isExpand;
  final String assets;
  final GestureTapCallback? onTap;
  final Widget child;

  const ExpandedWidget(
      {super.key,
      required this.isExpand,
      required this.assets,
      this.onTap,
      required this.child});
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          GestureDetector(
              onTap: onTap,
              child: Stack(children: [
                Image.asset(assets),
                Positioned(
                    top: 0,
                    bottom: 0,
                    right: 10,
                    child: Center(
                        child: Row(children: [
                      Text(isExpand ? "收起" : "展开",
                          style: TextStyle(color: c_9ea7b8)),
                      Icon(
                          isExpand
                              ? Icons.keyboard_arrow_up_rounded
                              : Icons.keyboard_arrow_down_rounded,
                          color: c_9ea7b8)
                    ])))
              ])),
          isExpand
              ? Container(
                  width: double.infinity,
                  padding: const EdgeInsets.all(13),
                  decoration: BoxDecoration(
                      color: const Color(0xff1B232F),
                      border: Border.all(color: const Color(0xff233643)),
                      borderRadius: const BorderRadius.vertical(
                          bottom: Radius.circular(5))),
                  child: child,
                )
              : Container(),
        ],
      ),
    );
  }
}
